'\" t
'\"! tbl | mmdoc
'\"macro stdmacro
.ds Vn Version 1.2
.ds Dt 24 September 1999
.ds Re Release 1.2.1
.ds Dp Jan 14 18:30
.ds Dm 01 colortabl
.ds Xs 60942 11 colortable.gl
.TH GLCOLORTABLE 3G
.SH NAME
.B "glColorTable
\- define a color lookup table

.SH C SPECIFICATION
void \f3glColorTable\fP(
GLenum \fItarget\fP,
.nf
.ta \w'\f3void \fPglColorTable( 'u
	GLenum \fIinternalformat\fP,
	GLsizei \fIwidth\fP,
	GLenum \fIformat\fP,
	GLenum \fItype\fP,
	const GLvoid \fI*table\fP )
.fi

.SH PARAMETERS
.TP \w'\fIinternalformat\fP\ \ 'u 
\f2target\fP
Must be one of
\%\f3GL_COLOR_TABLE\fP,
\%\f3GL_POST_CONVOLUTION_COLOR_TABLE\fP,
\%\f3GL_POST_COLOR_MATRIX_COLOR_TABLE\fP,
\%\f3GL_PROXY_COLOR_TABLE\fP,
\%\f3GL_PROXY_POST_CONVOLUTION_COLOR_TABLE\fP,
or
\%\f3GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE\fP.
.TP
\f2internalformat\fP
The internal  of the color table.
The allowable values are
\%\f3GL_ALPHA\fP,
\%\f3GL_ALPHA4\fP,
\%\f3GL_ALPHA8\fP,
\%\f3GL_ALPHA12\fP,
\%\f3GL_ALPHA16\fP,
\%\f3GL_LUMINANCE\fP,
\%\f3GL_LUMINANCE4\fP,
\%\f3GL_LUMINANCE8\fP,
\%\f3GL_LUMINANCE12\fP,
\%\f3GL_LUMINANCE16\fP,
\%\f3GL_LUMINANCE_ALPHA\fP,
\%\f3GL_LUMINANCE4_ALPHA4\fP,
\%\f3GL_LUMINANCE6_ALPHA2\fP,
\%\f3GL_LUMINANCE8_ALPHA8\fP,
\%\f3GL_LUMINANCE12_ALPHA4\fP,
\%\f3GL_LUMINANCE12_ALPHA12\fP,
\%\f3GL_LUMINANCE16_ALPHA16\fP,
\%\f3GL_INTENSITY\fP,
\%\f3GL_INTENSITY4\fP,
\%\f3GL_INTENSITY8\fP,
\%\f3GL_INTENSITY12\fP,
\%\f3GL_INTENSITY16\fP,
\%\f3GL_R3_G3_B2\fP,
\%\f3GL_RGB\fP,
\%\f3GL_RGB4\fP,
\%\f3GL_RGB5\fP,
\%\f3GL_RGB8\fP,
\%\f3GL_RGB10\fP,
\%\f3GL_RGB12\fP,
\%\f3GL_RGB16\fP,
\%\f3GL_RGBA\fP,
\%\f3GL_RGBA2\fP,
\%\f3GL_RGBA4\fP,
\%\f3GL_RGB5_A1\fP,
\%\f3GL_RGBA8\fP,
\%\f3GL_RGB10_A2\fP,
\%\f3GL_RGBA12\fP, and
\%\f3GL_RGBA16\fP.
.TP
\f2width\fP
The number of entries in the color lookup table specified by \f2table\fP.
.TP
\f2format\fP
The  of the pixel data in \f2table\fP.
The allowable values are
\%\f3GL_RED\fP,
\%\f3GL_GREEN\fP,
\%\f3GL_BLUE\fP,
\%\f3GL_ALPHA\fP,
\%\f3GL_LUMINANCE\fP,
\%\f3GL_LUMINANCE_ALPHA\fP,
\%\f3GL_RGB\fP,
\%\f3GL_BGR\fP,
\%\f3GL_RGBA\fP, and
\%\f3GL_BGRA\fP.
.TP
\f2type\fP
The type of the pixel data in \f2table\fP.
The allowable values are
\%\f3GL_UNSIGNED_BYTE\fP,
\%\f3GL_BYTE\fP,
\%\f3GL_UNSIGNED_SHORT\fP,
\%\f3GL_SHORT\fP,
\%\f3GL_UNSIGNED_INT\fP,
\%\f3GL_INT\fP,
\%\f3GL_FLOAT\fP,
\%\f3GL_UNSIGNED_BYTE_3_3_2\fP,
\%\f3GL_UNSIGNED_BYTE_2_3_3_REV\fP,
\%\f3GL_UNSIGNED_SHORT_5_6_5\fP,
\%\f3GL_UNSIGNED_SHORT_5_6_5_REV\fP,
\%\f3GL_UNSIGNED_SHORT_4_4_4_4\fP,
\%\f3GL_UNSIGNED_SHORT_4_4_4_4_REV\fP,
\%\f3GL_UNSIGNED_SHORT_5_5_5_1\fP,
\%\f3GL_UNSIGNED_SHORT_1_5_5_5_REV\fP,
\%\f3GL_UNSIGNED_INT_8_8_8_8\fP,
\%\f3GL_UNSIGNED_INT_8_8_8_8_REV\fP,
\%\f3GL_UNSIGNED_INT_10_10_10_2\fP, and
\%\f3GL_UNSIGNED_INT_2_10_10_10_REV\fP.
.TP
\f2table\fP
Pointer to a one-dimensional array of pixel data that is processed to
build the color table.
.SH DESCRIPTION
\%\f3glColorTable\fP may be used in two ways: 
to test the actual size and color resolution of a lookup table
given a particular set of parameters,
or to load the contents of a color lookup
table.
Use the targets \%\f3GL_PROXY_*\fP for the first case
and the other targets for the second case. 
.P
If \f2target\fP is \%\f3GL_COLOR_TABLE\fP,
\%\f3GL_POST_CONVOLUTION_COLOR_TABLE\fP,
or
\%\f3GL_POST_COLOR_MATRIX_COLOR_TABLE\fP,
\%\f3glColorTable\fP builds a color lookup table from an array of pixels.
The pixel array specified by \f2width\fP, \f2format\fP, \f2type\fP, and \f2table\fP
is extracted from memory and
processed just as if \%\f3glDrawPixels\fP were called, but processing
stops after the final expansion to RGBA is completed.
.P
The four scale parameters and the four bias parameters that are defined
for the table are then used to scale and bias the R, G, B, and A components 
of each pixel.
(Use \%\f3glColorTableParameter\fP to set these scale and bias
parameters.)
.P
Next, the R, G, B, and A values are clamped to the range [0,\ 1].
Each pixel is then converted to the internal  specified by
\f2internalformat\fP.
This conversion simply maps the component values of the pixel (R, G, B,
and A) to the values included in the internal  (red, green, blue,
alpha, luminance, and intensity).  The mapping is as follows:
.P
.TS
center;
lb cb cb cb cb cb cb
l c c c c c c.
_
Internal Format	Red	Green	Blue	Alpha	Luminance	Intensity
_
\%\f3GL_ALPHA\fP				A
\%\f3GL_LUMINANCE\fP					R
\%\f3GL_LUMINANCE_ALPHA\fP				A	R
\%\f3GL_INTENSITY\fP						R
\%\f3GL_RGB\fP	R	G	B
\%\f3GL_RGBA\fP	R	G	B	A
_
.TE
.P
Finally, the red, green, blue, alpha, luminance, and/or intensity components of
the resulting pixels are stored in the color table.
They form a one-dimensional table with indices in the range
[0,\ \f2width\fP\ \-\ 1].
.P
If \f2target\fP is \%\f3GL_PROXY_*\fP,
\%\f3glColorTable\fP recomputes and stores the values of the proxy color table's state
variables
\%\f3GL_COLOR_TABLE_FORMAT\fP,
\%\f3GL_COLOR_TABLE_WIDTH\fP,
\%\f3GL_COLOR_TABLE_RED_SIZE\fP,
\%\f3GL_COLOR_TABLE_GREEN_SIZE\fP,
\%\f3GL_COLOR_TABLE_BLUE_SIZE\fP,
\%\f3GL_COLOR_TABLE_ALPHA_SIZE\fP,
\%\f3GL_COLOR_TABLE_LUMINANCE_SIZE\fP, and
\%\f3GL_COLOR_TABLE_INTENSITY_SIZE\fP.
There is no effect on the image or state of any actual color table.
If the specified color table is too large to be supported, then all the
proxy state variables listed above are set to zero.
Otherwise, the color table could be supported by \%\f3glColorTable\fP
using the corresponding non-proxy target,
and the proxy state variables are set as if that target were being defined.
.P
The proxy state variables can be retrieved by calling
\%\f3glGetColorTableParameter\fP with a target of
\%\f3GL_PROXY_*\fP.
This allows the application to decide if a particular \%\f3glColorTable\fP
command would succeed, and to determine what the resulting color table
attributes would be.
.P
If a color table is enabled, and its width is non-zero, then its
contents are used to replace a subset of the components of each RGBA
pixel group, based on the internal  of the table.
.P
Each pixel group has color components (R, G, B, A)
that are in the range [0.0,\ 1.0].
The color components are rescaled to
the size of the color lookup table to form an index.
Then a subset of the components based on the internal  of the table are
replaced by the table entry selected by that index.
If the color components and contents of the table are represented as follows:
.P
.TS
center;
cb cb
c l.
_
Representation	Meaning
_
\f7r\fP	Table index computed from \f7R\fP
\f7g\fP	Table index computed from \f7G\fP
\f7b\fP	Table index computed from \f7B\fP
\f7a\fP	Table index computed from \f7A\fP
\f7L[i]\fP	Luminance value at table index \f7i\fP
\f7I[i]\fP	Intensity value at table index \f7i\fP
\f7R[i]\fP	Red value at table index \f7i\fP
\f7G[i]\fP	Green value at table index \f7i\fP
\f7B[i]\fP	Blue value at table index \f7i\fP
\f7A[i]\fP	Alpha value at table index \f7i\fP
_
.TE
.P
then the result of color table lookup is as follows:
.P
.ne 10
.TS
center;
l l s s s
l l l l l
l l l l l.
_
	Resulting Texture Components
Table Internal Format	R	G	B	A
_
\%\f3GL_ALPHA\fP	R	G	B	A[a]
\%\f3GL_LUMINANCE\fP	L[r]	L[g]	L[b]	At
\%\f3GL_LUMINANCE_ALPHA\fP	L[r]	L[g]	L[b]	A[a]
\%\f3GL_INTENSITY\fP	I[r]	I[g]	I[b]	I[a]
\%\f3GL_RGB\fP	R[r]	G[g]	B[b]	A
\%\f3GL_RGBA\fP	R[r]	G[g]	B[b]	A[a]
_
.TE
.P
When \%\f3GL_COLOR_TABLE\fP is enabled, the colors resulting from
the pixel map operation (if it is enabled) are mapped
by the color lookup table before being passed to the convolution
operation. The colors resulting from the convolution operation
are modified by the post convolution color lookup table when 
\%\f3GL_POST_CONVOLUTION_COLOR_TABLE\fP
is enabled. These modified colors are then sent to the color matrix operation. 
Finally, if \%\f3GL_POST_COLOR_MATRIX_COLOR_TABLE\fP
is enabled, the colors resulting from the color matrix operation 
are mapped by the post color matrix color lookup table before being 
used by the histogram operation.
.P
.SH NOTES
\%\f3glColorTable\fP is present only if \%\f3GL_ARB_imaging\fP is returned when \%\f3glGetString\fP
is called with an argument of \%\f3GL_EXTENSIONS\fP.
.P
If \f2target\fP is set to \%\f3GL_COLOR_TABLE\fP,
\%\f3GL_POST_CONVOLUTION_COLOR_TABLE\fP,
or \%\f3GL_POST_COLOR_MATRIX_COLOR_TABLE\fP,
then \f2width\fP must be a power of two or a \%\f3GL_INVALID_VALUE\fP
error is generated.
.P
.SH ERRORS
\%\f3GL_INVALID_ENUM\fP is generated if \f2target\fP is not one of the allowable
values.
.P
\%\f3GL_INVALID_ENUM\fP is generated if \f2internalformat\fP is not one of the
allowable values.
.P
\%\f3GL_INVALID_VALUE\fP is generated if \f2width\fP is less than zero.
.P
\%\f3GL_INVALID_ENUM\fP is generated if \f2format\fP is not one of the allowable
values.
.P
\%\f3GL_INVALID_ENUM\fP is generated if \f2type\fP is not one of the allowable
values.
.P
\%\f3GL_TABLE_TOO_LARGE\fP is generated if the requested color table
is too large to be supported by the implementation, and \f2target\fP is
not a \%\f3GL_PROXY_*\fP target.
.P
\%\f3GL_INVALID_OPERATION\fP is generated if \%\f3glColorTable\fP is executed
between the execution of \%\f3glBegin\fP and the corresponding
execution of \%\f3glEnd\fP.
.SH ASSOCIATED GETS
\%\f3glGetColorTableParameter\fP
.SH SEE ALSO
\%\f3glColorSubTable(3G)\fP,
\%\f3glColorTableParameter(3G)\fP,
\%\f3glCopyColorTable(3G)\fP,
\%\f3glCopyColorSubTable(3G)\fP,
\%\f3glGetColorTable(3G)\fP
